<%@page pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--使用EL表达式--%>
<%@page isELIgnored="false" %>
<html>
<link rel="stylesheet" type="text/css" href="../css/login.css">
<style>
    label {
        margin-left: 40%;
        color: red;
    }
</style>
<body>
<div id="login">

    <h1>RENEW</h1><br>

    <form method="post" action="${pageContext.request.contextPath}/login">
        账号：<input type="text" name="username" placeholder="请输入您的账号" class="enroll" id="username">
        <a href="#">忘记账号？</a> <br>
        密码：<input type="password" name="password" placeholder="请输入您的密码" class="enroll" id="password">
        <a href="#">忘记密码？</a><br>
        <label id="label">${requestScope.loginError}</label>
        <span>${errorInfo}</span>
        <div id="check_div">
            <input type="text" name="checkCode" placeholder="请输入验证码" id="check">
            <img id="checkImg" src="${pageContext.request.contextPath}/check">
            <a href="#" id="checkSet">看不清？</a><br>
        </div>
        <input type="submit" value="登录" class="button" onclick="return isEmpty()"><br>
        <input type="button" value="重置" class="button" onclick="setEmpty()">
    </form>

</div>

</body>

<script>
    document.getElementById("checkSet").onclick = function () {
        document.getElementById("checkImg").src = "${pageContext.request.contextPath}/check?" + new Date().getMilliseconds();
    }
    document.getElementById("checkImg").onclick = function () {
        document.getElementById("checkImg").src = "${pageContext.request.contextPath}/check?" + new Date().getMilliseconds();
    }

    function isEmpty() {
        var checkCode = document.getElementById("check");
        var username = document.getElementById("username");
        var password = document.getElementById("password");
        if (username.value.length === 0 || password.value.length === 0) {
            window.alert("账号或密码不能为空！");
            return false;
        }
        if (checkCode.value.length === 0) {
            window.alert("验证码不能为空");
            return false;
        }
        return true;
    }

    function setEmpty() {
        document.getElementById("check").value = "";
        document.getElementById("username").value = "";
        document.getElementById("password").value = "";
    }

</script>
</html>






